home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Memphis Amiga Group / MAG DOS 2.0 Utilities Disk 01 (1991-09)(Memphis Amiga Group).zip / MAG DOS 2.0 Utilities Disk 01 (1991-09)(Memphis Amiga Group).adf / Back&Front / myparseix.c < prev    next >
C/C++ Source or Header  |  1991-08-17  |  3KB  |  107 lines

  1. /*
  2.  *  myparseix.c - frontend to ParseIX() to allow trapping of mousebutton codes
  3.  *
  4.  *  Author: Stefan Sticht
  5.  *
  6.  *  Version history:
  7.  *
  8.  *  V1.00   initial hack
  9.  */
  10.  
  11. /********************************************************************
  12.  *                             interfacing                          *
  13.  ********************************************************************/
  14.  
  15. /*
  16.  *  include files
  17.  */
  18. #include <string.h>
  19. #include <devices/inputevent.h>
  20. #include <libraries/commodities.h>
  21. #include <clib/commodities_protos.h>
  22. #include <pragmas/commodities_pragmas.h>
  23.  
  24. #ifdef DEBUG
  25. #define printf KPrintF
  26. #include <clib/dlib_protos.h>
  27. #endif
  28.  
  29. extern struct Library *CxBase;
  30.  
  31. /********************************************************************
  32.  *                             functions                            *
  33.  ********************************************************************/
  34.  
  35. long myparseix(char *description, IX *ix)
  36. {
  37.     char blanks[] = "           ";
  38.     char *pos;
  39.     long failurecode = 0l;
  40.     UWORD code = 0;
  41.  
  42.     /*
  43.      *  parse and remove our special keywords
  44.      *
  45.      */
  46.     if (pos = strstr(description, "lbuttoncode")) {
  47.         code |= IECODE_LBUTTON;
  48.         strncpy(pos, blanks, 11l);
  49.         }
  50.     else if (pos = strstr(description, "rbuttoncode")) {
  51.         code |= IECODE_RBUTTON;
  52.         strncpy(pos, blanks, 11l);
  53.         }
  54.     else if (pos = strstr(description, "mbuttoncode")) {
  55.         code |= IECODE_MBUTTON;
  56.         strncpy(pos, blanks, 11l);
  57.         }
  58.  
  59.     while (*description && (*description == ' ')) description++;
  60.  
  61.     #ifdef DEBUG
  62.     printf("myparseix(): description is %s\n", description);
  63.     #endif
  64.  
  65.     #ifdef DEBUG
  66.     printf("\nmyparseix(): calling ParseIX()!!!\n");
  67.     #endif
  68.     if (*description) failurecode = ParseIX((UBYTE *)description, ix);
  69.     #ifdef DEBUG
  70.     printf("\nmyparseix(): after ParseIX()!!!\n");
  71.     #endif
  72.  
  73.     /*
  74.      *  now change ix for our new keywords
  75.      *
  76.      */
  77.     if (code) {
  78.         ix->ix_Code |= code;
  79.         /*
  80.          *  change also QualMask for mouse buttons
  81.          *
  82.          */
  83.         ix->ix_QualMask |= IEQUALIFIER_MIDBUTTON | IEQUALIFIER_RBUTTON | IEQUALIFIER_LEFTBUTTON;
  84.  
  85.         /*
  86.          *  parse for qualifiers the use wants to be considered irrelevant
  87.          *
  88.          */
  89.         if (strstr(description, "-leftbutton")) ix->ix_QualMask &= ~IEQUALIFIER_LEFTBUTTON;
  90.         if (strstr(description, "-midbutton")) ix->ix_QualMask &= ~IEQUALIFIER_MIDBUTTON;
  91.         if (strstr(description, "-rbutton")) ix->ix_QualMask &= ~IEQUALIFIER_RBUTTON;
  92.         }
  93.  
  94.     #ifdef DEBUG
  95.     printf("ix_Version      = %ld\n", ix->ix_Version);
  96.     printf("ix_Class        = 0x%lx\n", ix->ix_Class);
  97.     printf("ix_Code         = 0x%lx\n", ix->ix_Code);
  98.     printf("ix_CodeMask     = 0x%lx\n", ix->ix_CodeMask);
  99.     printf("ix_Qualifier    = 0x%lx\n", ix->ix_Qualifier);
  100.     printf("ix_QualMask     = 0x%lx\n", ix->ix_QualMask);
  101.     printf("ix_QualSame     = 0x%lx\n", ix->ix_QualSame);
  102.     if (failurecode) printf("myparseix(): failed!\n");
  103.     #endif
  104.  
  105.     return(failurecode);
  106. }
  107.